<template>
  <div class="taskMDialog increDia">
    <el-dialog
      title="增量字段选择"
      :visible.sync="innerVisible"
      width="60%"
      :close-on-click-modal="false"
      :before-close="closeDialog"
      :append-to-body="true"
    >
      <div class="dialog-block">
        <div class="proInfo-box clearfix">
          <div class="comTable">
            <el-table :data="list" stripe height="480">
              <el-table-column label="增量字段选择" width="120">
                <template slot-scope="scope">
                  <el-radio
                    @change.native="getCurrentRow(scope.row)"
                    :label="scope.row.logicColumnName"
                    v-model="radio"
                    class="textRadio"
                  >&nbsp;</el-radio>
                </template>
              </el-table-column>
              <el-table-column prop="logicColumnName" label="字段名" width="180"></el-table-column>
              <el-table-column label="字段类型" prop="logicColumnType"></el-table-column>
            </el-table>
          </div>
        </div>
      </div>
      <div slot="footer" class="dialog-footer">
        <el-button @click="closeDialog()">取消</el-button>
        <el-button type="primary" @click="save('')">确定</el-button>
      </div>
    </el-dialog>
  </div>
</template>
<script>
export default {
  data: function() {
    return {
      radio: "",
      innerVisible: this.msg,
      appId: "",
      cincreArr: {},
      flag: "",
      list: []
    };
  },
  methods: {
    //关闭对话框
    closeDialog() {
      this.radio = "";
      this.$emit("showIncre");
    },
    getCurrentRow(row) {
      this.cincreArr = row;
    },
    save() {
      if (!this.cincreArr.logicColumnName) {
        this.$message({
          message: "还未选择增量字段",
          type: "warning"
        });
      }
      this.$emit("saveIncre", {
        datatype: this.cincreArr.logicColumnType,
        id: this.cincreArr.id,
        name: this.cincreArr.logicColumnName
      });
    },
    //获取增量字段-从映射schemaDTOMappingList中获取
    getIncreData(data) {
      this.list = data.filter(item => {
        return item.logicColumnName && item;
      });
    },
    initMap() {
      this.cincreArr = {};
      this.radio = "";
    }
  },
  components: {},
  created() {},
  props: ["msg", "alincre", "incid", "yid", "tableData"],
  watch: {
    msg() {
      this.innerVisible = this.msg;
      this.radio = this.alincre && this.alincre.name ? this.alincre.name : "";
    },
    tableData: {
      handler(val) {
        if (val && val.length > 0) {
          this.getIncreData(val);
        }
      },
      immediate: true
    }
  }
};
</script>
<style lang="scss" scoped>
.mr-btn {
  text-align: right;
}
.otherInfo .el-radio {
  margin-bottom: 12px;
  margin-top: 8px;
  margin-left: 30px;
}
.dialog-block {
  height: 430px;
  padding: 10px;
  overflow: auto;
}
</style>
